package thread1;

public class MyThread1 extends Thread {
	public MyThread1(String name) {
		super(name);
	}

	@Override
	public void run() {
		for (int i = 1; i <= 20; i++) {
			System.out.println(super.getName() + " print " + i);
			super.yield();// 不会出现一个线程连续输出两次
		}
	}

	public static void main(String[] args) {
		System.out.println("主线程：" + Thread.currentThread().getName());
		// for (int i = 1; i <= 3; i++) {
		// new MyThread1("线程" + i).start();
		// }
		MyThread1 t1 = new MyThread1("线程" + 1);
		t1.setPriority(Thread.MIN_PRIORITY);
		t1.start();
		MyThread1 t2 = new MyThread1("线程" + 2);
		t2.setPriority(Thread.NORM_PRIORITY);
		t2.start();

		MyThread1 t3 = new MyThread1("线程" + 3);
		t3.setPriority(Thread.MAX_PRIORITY);
		t3.start();
	}
}
